﻿using System.ComponentModel;

namespace MyFloridaHouse.libSvOpenDistricts.ViewModel
{
    public partial class ViewModelBase
    {
        private void InitializePropertyChangedListener()
        {
            PropertyChanged += new PropertyChangedEventHandler(ViewModelPropertyChanged);
            regionFill.PropertyChanged += new PropertyChangedEventHandler(OnRegionFillPropertyChanged);
            districtPlan.PropertyChanged += new PropertyChangedEventHandler(OnMemberPropertyChanged);
        }

        public void OnRegionFillPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "isRegionFillOn")
            {
                CmdBuildShaded.RaiseCanExecuteChanged();
            }
        }

        private void OnMemberPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            NotifyPropertyChanged(e.PropertyName);
        }

        private void ViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "mapMode")
            {
                mapLasso.Reset(getLassoMode());
            }
            else if (e.PropertyName == "minZoomLevel")
            {
                MapDataRefresh();
            }
            else if (e.PropertyName == "maxZoomLevel")
            {
                MapDataRefresh();
            }            
            else if ((e.PropertyName == "isRegionsDataDictionaryInitializeCompleted")
                    | (e.PropertyName == "isCensusGeometryInitializeCompleted")
                    | (e.PropertyName == "isDistrictPlanTypesInitializeCompleted")
                    | (e.PropertyName == "isLayersInitializeCompleted")
                    )
            {
                NotifyPropertyChanged("isInitializeComplete");
            }            

        }


    }
}
